<?php 
/*
 module:		订单列表
 create_time:	2024-05-06 12:04:05
 author:		
 contact:		
*/

namespace app\admin\controller\Order;

use app\admin\service\Order\IndexService;
use app\admin\model\Order\Index as IndexModel;
use app\admin\controller\Admin;
use think\facade\Db;

class Index extends Admin {


	/*首页数据列表*/
	function index(){
		if (!$this->request->isAjax()){
			return view('index');
		}else{
			$limit  = $this->request->post('limit', 20, 'intval');
			$offset = $this->request->post('offset', 0, 'intval');
			$page   = floor($offset / $limit) +1 ;

			$where = [];
			$where['order_son'] = $this->request->param('order_son', '', 'serach_in');
			$where['phone'] = $this->request->param('phone', '', 'serach_in');
			$where['pay_type'] = $this->request->param('pay_type', '', 'serach_in');
			$where['state'] = $this->request->param('state', '', 'serach_in');

			$pay_time_start = $this->request->param('pay_time_start', '', 'serach_in');
			$pay_time_end = $this->request->param('pay_time_end', '', 'serach_in');

			$where['pay_time'] = ['between',[strtotime($pay_time_start),strtotime($pay_time_end)]];

			$order  = $this->request->post('order', '', 'serach_in');	//排序字段 bootstrap-table 传入
			$sort  = $this->request->post('sort', '', 'serach_in');		//排序方式 desc 或 asc

			$field = 'order_id,order_son,title,price,money,actual_price,pay_type,state,create_time,update_time,pay_time';
			$orderby = ($sort && $order) ? $sort.' '.$order : 'order_id desc';

			$res = IndexService::indexList(formatWhere($where),$field,$orderby,$limit,$page);
			return json($res);
		}
	}



}

